/*
 * @Author: byAcya xiaoxianbin@4399inc.com
 * @Date: 2025-02-10 11:36:48
 * @LastEditors: byAcya xiaoxianbin@4399inc.com
 * @LastEditTime: 2025-02-10 13:38:36
 * @FilePath: \CocosFramework\assets\script\core\utils\AngleUtils.ts
 * @Description: 角度 弧度
 */
import Instance from './Instance';

export interface IAngleUtils {
    getAngle(a: number): number; //弧度转角度
    getRadian(a: number): number; //角度转弧度
    getRadianByPoint(p1X: number, p1Y: number, p2X: number, p2Y: number): number; //获取两点弧度
}

export class AngleUtils implements IAngleUtils {
    public static getInstance(): AngleUtils {
        return Instance.get<AngleUtils>(AngleUtils);
    }

    getAngle(a: number): number {
        return a * (180 / Math.PI);
    }

    getRadian(a: number): number {
        return (a / 180) * Math.PI;
    }

    getRadianByPoint(p1X: number, p1Y: number, p2X: number, p2Y: number): number {
        const dX = p2X - p1X;
        const dY = p2Y - p1Y;
        return Math.atan2(dY, dX);
    }
}
